<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随便逛逛布局</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #333;
            color: #fff;
            padding: 10px 20px;
        }
        header nav a {
            color: #fff;
            text-decoration: none;
            margin: 0 10px;
        }
        .search-bar {
            flex-grow: 1;
            margin: 0 20px;
        }
        .search-bar input {
            width: 100%;
            padding: 5px;
        }
        .carousel {
            background-color: #ddd;
            height: 200px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 20px 0;
            font-size: 24px;
            color: #555;
        }
        .tabs {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }
        .tabs .categories, .tabs .filters {
            display: flex;
            gap: 10px;
        }
        .tabs button {
            padding: 10px 20px;
            border: none;
            background-color: #007bff;
            color: #fff;
            cursor: pointer;
        }
        .tabs button:hover {
            background-color: #0056b3;
        }
        img{
            width: 250px;
            height: 250px;
        }
        .gallery {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
        }
        .gallery .item {
            background-color: #fff;
            border: 1px solid #ddd;
            padding: 10px;
            text-align: center;
            position: relative;
        }
        .gallery .item .actions {
            display: flex;
            justify-content: space-around;
            margin-top: 10px;
        }
        .gallery .item .actions button {
            padding: 5px 10px;
            border: none;
            background-color: #007bff;
            color: #fff;
            cursor: pointer;
        }
        .gallery .item .actions button:hover {
            background-color: #0056b3;
        }
        .recommendations {
            margin: 20px 0;
        }
        .recommendations h2 {
            margin-bottom: 10px;
        }
        .recommendations .content {
            display: flex;
            gap: 20px;
        }
        .recommendations .content div {
            flex: 1;
            background-color: #fff;
            padding: 20px;
            text-align: center;
        }
        footer {
            background-color: #333;
            color: #fff;
            text-align: center;
            padding: 20px;
            margin-top: 20px;
        }
        .modal {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #fff;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            width: 400px;
            text-align: center;
        }
        .modal.active {
            display: block;
        }
        .overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 999;
        }
        .overlay.active {
            display: block;
        }
        .payment-methods {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin: 20px 0;
        }
        .payment-methods img {
            width: 50px;
            height: 50px;
            cursor: pointer;
            border: 2px solid transparent;
        }
        .payment-methods img.selected {
            border-color: #007bff;
        }
        .modal button {
            padding: 10px 20px;
            margin: 10px;
            border: none;
            background-color: #007bff;
            color: #fff;
            cursor: pointer;
        }
        .modal button:hover {
            background-color: #0056b3;
        }
        .filter-buttons {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }
        .filter-buttons button {
            padding: 10px 20px;
            border: none;
            background-color: #007bff;
            color: #fff;
            cursor: pointer;
        }
        .filter-buttons button.active {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 头部 -->
        <header>
            <nav>
                <a href="./user.html">个人页面</a>
                <a href="./productivitydemo.html">收藏夹</a>
                <a href="#">关于我们</a>
            </nav>
            <div class="search-bar">
                <input type="text" placeholder="搜索作品或艺术家...">
            </div>
            <div>
                <a href="./login.html">登录</a> | 
                <a href="./login.html">注册</a> | 
                <button onclick="showModal()">充值付费</button>
            </div>
        </header>

        <!-- 轮播图 -->
        <div class="carousel">
            轮播图/推荐作品
        </div>

        <!-- 推荐内容 -->
        <div class="recommendations">
            <h2>热门推荐</h2>
            <div class="content">
                <div>热门作品</div>
                <div>VIP专区</div>
                <div>最新上传</div>
            </div>
        </div>

         <!-- 标签栏 -->
         <div class="tabs">
            <div class="categories">
                <input type="checkbox" value="1" name="style[]"/>风景
                <input type="checkbox" value="2" name="style[]"/>人物
                <input type="checkbox" value="3" name="style[]"/>抽象
                <input type="checkbox" value="4" name="style[]"/>二次元
                <input type="checkbox" value="4" name="style[]"/>其他
                <button>筛选</button>
            </div>
            <div class="filters">
                <select>
                    <option>收藏最多</option>
                    <option>最受欢迎</option>
                </select>
                
            </div>
        </div>

        <!-- 筛选按钮 -->
        <div class="filter-buttons">
            <button class="active" onclick="filterImages('all')">全部</button>
            <button onclick="filterImages('free')">免费</button>
            <button onclick="filterImages('vip')">VIP</button>
        </div>

        <!-- 作品展示 -->
        <div class="gallery" id="gallery">
            <!-- 图片将通过JavaScript动态加载 -->
        </div>

        <!-- 页脚 -->
        <footer>
            <p>关于我们 | 联系方式 | 隐私政策 | 服务条款</p>
            <p>© 2025 MJ SEED</p>
        </footer>

        <!-- 弹窗 -->
        <div class="overlay" id="overlay"></div>
        <div class="modal" id="modal">
            <h2>选择支付方式</h2>
            <div class="payment-methods">
                <img src="./wx_logo.png" alt="微信支付" onclick="selectPayment('wechat')" id="wechat">
                <img src="./zfb_logo.png" alt="支付宝支付" onclick="selectPayment('alipay')" id="alipay">
            </div>
            <div id="qr-code">
                <!-- 二维码图片将根据选择的支付方式动态加载 -->
                <img src="./2420.jpg_wh860.jpg" alt="微信支付二维码" id="qr-image">
            </div>
            <button onclick="confirmPayment()">确认支付</button>
            <button onclick="hideModal()">关闭</button>
        </div>
    </div>

    <script>
        // 显示弹窗
        function showModal() {
            document.getElementById('modal').classList.add('active');
            document.getElementById('overlay').classList.add('active');
        }

        // 隐藏弹窗
        function hideModal() {
            document.getElementById('modal').classList.remove('active');
            document.getElementById('overlay').classList.remove('active');
        }

        // 选择支付方式
        function selectPayment(method) {
            const wechat = document.getElementById('wechat');
            const alipay = document.getElementById('alipay');
            const qrImage = document.getElementById('qr-image');

            if (method === 'wechat') {
                wechat.classList.add('selected');
                alipay.classList.remove('selected');
                qrImage.src = './wx_logo.png';
            } else if (method === 'alipay') {
                alipay.classList.add('selected');
                wechat.classList.remove('selected');
                qrImage.src = './zfb_logo.png';
            }
        }

        // 确认支付
        function confirmPayment() {
            const selectedPayment = document.querySelector('.payment-methods img.selected');
            if (selectedPayment) {
                alert('支付成功！');
                hideModal();
            } else {
                alert('请选择支付方式！');
            }
        }

        // 复制图片
        function copyImage() {
            alert('复制成功！');
        }

        // 下载图片
        function downloadImage() {
            alert('下载成功！');
        }

        // 获取图片数据
        async function fetchImages() {
            try {
                const response = await fetch('http://127.0.0.1:5000/admin/images');
                
                const data = await response.json();
                console.log(data);
                return data;
            } catch (error) {
                console.error('Error fetching images:', error);
            }
        }

        // 渲染图片列表
        function renderImages(images) {
            const gallery = document.getElementById('gallery');
            gallery.innerHTML = '';
            images.forEach(image => {
                const item = document.createElement('div');
                item.className = 'item';
                item.innerHTML = `
                    <a href="./detailspage.html?image_id=${image.image_id}">
                        <img src="${image.oss_path}" alt="${image.image_title}">
                    </a>
                    <h3 style="margin: 10px 0 5px; font-size: 1.1em;">${image.image_title}</h3>
                    <p style="margin: 0; color: #666; font-size: 0.9em;">${image.image_description}</p>
                    <div class="actions">
                        <button onclick="copyImage()">复制</button>
                        <button onclick="downloadImage()">下载</button>
                        <button onclick="alert('收藏成功！');">收藏</button>
                    </div>
                `;
                gallery.appendChild(item);
            });
    }


        // 筛选图片
        function filterImages(filter) {
            const buttons = document.querySelectorAll('.filter-buttons button');
            buttons.forEach(button => button.classList.remove('active'));
            document.querySelector(`.filter-buttons button[onclick="filterImages('${filter}')"]`).classList.add('active');

            fetchImages().then(images => {
                if (filter === 'all') {
                    renderImages(images);
                } else if (filter === 'free') {
                    const freeImages = images.filter(image => image.vip_exclusive === 'no');
                    renderImages(freeImages);
                } else if (filter === 'vip') {
                    const vipImages = images.filter(image => image.vip_exclusive === 'yes');
                    renderImages(vipImages);
                }
            });
        }

        // 初始化页面
        document.addEventListener('DOMContentLoaded', () => {
            filterImages('all');
        });
    </script>
</body>
</html>